package com.yizhuoyan.his.dto;

import com.yizhuoyan.his.entity.HosNodrugEntity;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 非药品收费项目返回数据
 * author:ZJH
 */
@Data
public class HosNodrugDto {
    //ID主键
    private Long id;

    //项目编码
    private String code;

    //项目名称
    private String name;

    //规格
    private String specification;

    //单价(分)
    private Integer unitPrice;

    //所属费用科目名
    private String expenseCategoryName;

    //执行科室
    private String departmentName;

    //拼音助记码
    private String mnemonic;

    //创建时间
    private LocalDateTime createTime;

    //最后修改时间
    private LocalDateTime updateTime;

    //项目类型(1-检查/2-检验/3-处置)
    private String itemType;

    public static HosNodrugDto transform(HosNodrugEntity entity) {
        HosNodrugDto dto = new HosNodrugDto();
        dto.setId(entity.getId());
        dto.setCode(entity.getCode());
        dto.setName(entity.getName());
        dto.setSpecification(entity.getSpecification());
        dto.setUnitPrice(entity.getUnitPrice());
        dto.setMnemonic(entity.getMnemonic());
        dto.setCreateTime(entity.getCreateTime());
        dto.setUpdateTime(entity.getUpdateTime());
        dto.setItemType(getType(entity.getItemType()));
        return dto;
    }

    private static String getType(Integer typeCode) {
        if(typeCode==null){
            return null;
        }
        String type;
        type = typeCode == 1 ? "检查" : typeCode == 2 ? "检验" : "处置";
        return type;
    }
}
